<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>$children</title>
</head>

<body>
  <div id="app">
    <cpn></cpn>
    <cpn></cpn>
    <button @click='showCpn'>点击</button>
  </div>
  <template id="cpn">
    <div>
      <p>我是子组件</p>
    </div>
  </template>
  <script src="../../vue.js"></script>
  <script>
    new Vue({
      el: '#app',
      methods: {
        showCpn() {
          console.log(this.$children);
          console.log(this.$children[0].show());
          console.log(this.$children[0].name);
        }
      },
      components: {
        cpn: {
          template: '#cpn',
          data() {
            return {
              name: '我叫胖虎'
            }
          },
          methods: {
            show() {
              console.log('子组件');
            }
          }
        }
      }
    })
  </script>
</body>

</html>